package com.area.cth.controller.admin;

import com.area.cth.common.PageBean;
import com.area.cth.common.Result;
import com.area.cth.pojo.CommentGoods;
import com.area.cth.pojo.CommentPost;
import com.area.cth.service.CommentService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "管理端评论相关接口")
@RestController("adminCommentController")
@RequestMapping("/admin/comment")
@CrossOrigin
public class CommentController {
    @Autowired
    private CommentService cs;

    @Operation(summary = "分页查询社区评论")
    @GetMapping("/getForPostList")
    public Result<PageBean<CommentPost>> commentPostList(Integer pageNo, Integer pageSize) {
        PageBean<CommentPost> commentPosts = cs.commentPostList(pageNo, pageSize);
        return Result.success(commentPosts);
    }
    //    @Operation(summary = "获取留言列表分页")
//    @GetMapping("/getForGoodsList")
//    public Result<IPage<CommentGoods>> commentGoodsList(Integer pageNo, Integer pageSize) {
//        IPage<CommentGoods> commentGoods = cs.commentGoodsList(pageNo, pageSize);
//        return Result.success(commentGoods);
//    }

    @Operation(summary = "删除帖子评论")
    @DeleteMapping("/delPost")
    public Result deletePost(Integer id) {
        cs.deletePost(id);
        return new Result(0,"删除成功",null);
    }

    @Operation(summary = "删除商品留言")
    @DeleteMapping("/delGoods")
    public Result deleteGoods(Integer id) {
        cs.deleteGoods(id);
        return new Result(0,"删除成功",null);
    }
}
